package thread.basepackage.t13;

/**
 * thread1 运行的比 thread2快
 * Created by cuihao on 2017/11/30.
 */
public class Run {
    public static void main(String[] args) {
        try {
            Thread1 thread1 = new Thread1();
            Thread2 thread2 = new Thread2();
            thread1.setPriority(Thread.NORM_PRIORITY + 3);
            thread2.setPriority(Thread.NORM_PRIORITY - 3);
            thread1.start();
            thread2.start();
            Thread.sleep(5000); // main线程在这休眠 5秒钟 不尽兴后面的操作（就是不执行stop操作），所以线程thread1和thread2可以统计5秒
            System.out.println(Thread.currentThread());
            thread1.stop();
            thread2.stop();
            System.out.println("thread1 = " + thread1.getCount());
            System.out.println("thread2 = " + thread2.getCount());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
